#ifndef DBUSMANAGER_H
#define DBUSMANAGER_H

#include <QObject>
#include <QDBusInterface>
#include <QDBusConnection>
#include <QDBusReply>
#include <QDebug>
#include <stdio.h>

//! 任务栏
#define PANEL_DBUS_SERVICE            "com.ukui.panel.desktop"
#define PANEL_DBUS_PATH               "/"
#define PANEL_DBUS_INTERFACE          "com.ukui.panel.desktop"

class PanelDbus : public QObject
{
public:
    PanelDbus();
    ~PanelDbus();

    static PanelDbus *getInstance();
    int getPanelHeight();
    int getPanelPosition();

private:
    QDBusInterface *m_panelInterface = nullptr;

};


//! 模式切换接口

#define STATUS_MANAGER_DBUS_SERVICE       "com.kylin.statusmanager.interface"
#define STATUS_MANAGER_DBUS_PATH          "/"
#define STATUS_MANAGER_DBUS_INTERFACE     "com.kylin.statusmanager.interface"

class StatusManagerDbus : public QObject
{
public:
    StatusManagerDbus();
    ~StatusManagerDbus();

    static StatusManagerDbus *getInstance();

    void setCurrentTabletMode(bool state);
    bool getCurrentTabletMode();

    void setAutoRotation(bool state);
    bool getAutoRotation();

private:
    QDBusInterface *m_statusManagerface = nullptr;

};


//! 消息通知

#define NOTIFICATION_DBUS_SERVICE               "org.freedesktop.Notifications"
#define NOTIFICATION_DBUS_PATH                  "/org/freedesktop/Notifications"
#define NOTIFICATION_DBUS_INTERFACE             "org.freedesktop.Notifications"

class NotificationsDbus : public QObject
{
public:
    NotificationsDbus();
    ~NotificationsDbus();

    static NotificationsDbus *getInstance();

    void SendMessage(QString title,QString describe,QString content);

private:
    QDBusInterface *m_notificationInterface = nullptr;

};

//! 侧边栏 core

#define SIDEBAR_CORE_DBUS_SERVICE          "org.ukui.Sidebar"
#define SIDEBAR_CORE_DBUS_PATH             "/org/ukui/Sidebar"
#define SIDEBAR_CORE_DBUS_INTERFACE        "org.ukui.Sidebar"

class SidebarCoreDbus : public QObject
{
public:
    SidebarCoreDbus();
    ~SidebarCoreDbus();

    static SidebarCoreDbus *getInstance();

    int getSidebarHeight();
    void sendAnimationActionSignal(uint time,int size);
    void sendAnimationStatusSignal(QString arg);

private:
    QDBusInterface *m_sidebarCoreInterface = nullptr;

};

//! 侧边栏 快捷操作面板

#define QUICK_OPERATION_DBUS_SERVICE          "org.ukui.Sidebar"
#define QUICK_OPERATION_DBUS_PATH             "/org/ukui/Sidebar/quick/operation"
#define QUICK_OPERATION_DBUS_INTERFACE        "org.ukui.Sidebar.quick.operation"
#define QUICK_OPERATION_DBUS_SIGNAL           "Sig_QuickOperation"

#define HEIGHT     420
#define HIDEHEIGHT 225

#define ANIMATIONSPEED 500

class SidebarQuickOperationDbus : public QObject
{
    Q_OBJECT
public:
    SidebarQuickOperationDbus();
    ~SidebarQuickOperationDbus();

    static SidebarQuickOperationDbus *getInstance();

    int getQuickOperationPanelHeight();
    int getQuickOperationPanelHideHeight();
    int getAnimationSpeed();

private:
    QDBusInterface *m_quickOperationInterface = nullptr;

private slots:
    void quickOperationSlot(QString arg);

Q_SIGNALS:
    void Sig_quickOperationSignal(QString arg);

};

//! 侧边栏 消息通知

#define SIDEBAR_NOTIFICATION_DBUS_SERVICE          "org.ukui.Sidebar"
#define SIDEBAR_NOTIFICATION_DBUS_PATH             "/org/ukui/Sidebar/notification"
#define SIDEBAR_NOTIFICATION_DBUS_INTERFACE        "org.ukui.Sidebar.notification"
#define SIDEBAR_NOTIFICATION_DBUS_SIGNAL           "Sig_NotificationNumChange"
#define SIDEBAR_NOTIFICATION_DBUS_ADD_NUM          "addNotificationNum"
#define SIDEBAR_NOTIFICATION_DBUS_SUB_NUM          "subNotificationNum"
#define SIDEBAR_NOTIFICATION_DBUS_CLEAR_NUM        "clearNotificationNum"
#define SIDEBAR_NOTIFICATION_DBUS_GET_NUM          "getNotificationNum"

class SidebarNotificationDbus : public QObject
{
    Q_OBJECT
public:
    SidebarNotificationDbus();
    ~SidebarNotificationDbus();

    static SidebarNotificationDbus *getInstance();

    void addNotificationNum();
    void subNotificationNum();
    void clearNotificationNum();
    int getNotificationNum();


private:
    QDBusInterface *m_notificationInterface = nullptr;

private slots:
    void notificationSlot();

Q_SIGNALS:
    void Sig_notificationSignal();

};


//! setting-daemon

#define SETTING_DAEMON_DBUS_SERVICE              "org.ukui.SettingsDaemon"
#define SETTING_DAEMON_DBUS_PATH                 "/org/ukui/SettingsDaemon/MediaKeys"
#define SETTING_DAEMON_DBUS_INTERFACE            "org.ukui.SettingsDaemon.MediaKeys"
#define SETTING_DAEMON_DBUS_GET_FLIGHT_STATE     "getFlightState"
#define SETTING_DAEMON_DBUS_SET_FLIGHT_STATE     "setFlightState"
#define SETTING_DAEMON_DBUS_FLIGHT_SIGNAL        "airModeStateChanged"

class SettingDaemonDbus : public QObject
{
    Q_OBJECT
public:
    SettingDaemonDbus();
    ~SettingDaemonDbus();

    static SettingDaemonDbus *getInstance();

    void setFlightState(bool state);
    int getFlightState();


private:
    QDBusInterface *m_settingDaemonInterface = nullptr;

private slots:
    void flightStateChange(int num);

Q_SIGNALS:
    void Sig_flightStateSignal(int num);

};

//! KWin

#define UKUI_KWIN_DBUS_SERVICE              "org.ukui.KWin"
#define UKUI_KWIN_DBUS_PATH                 "/ColorCorrect"
#define UKUI_KWIN_DBUS_INTERFACE            "org.ukui.kwin.ColorCorrect"
//#define SETTING_DAEMON_DBUS_GET_FLIGHT_STATE     "getFlightState"
//#define SETTING_DAEMON_DBUS_SET_FLIGHT_STATE     "setFlightState"


#define UKUI_KWIN_DBUS_ACTIVE false
#define UKUI_KWIN_DBUS_NIGHE 1

class KwinDbus : public QObject
{
    Q_OBJECT
public:
    KwinDbus();
    ~KwinDbus();

    static KwinDbus *getInstance();

    bool getActive();
    int  getNightTemperature();

    void setNightMode(bool state);


private:
    QDBusInterface *m_kWinInterface = nullptr;

private slots:

Q_SIGNALS:

};

//! bluetooth

#define KYLIN_BLUETOOTH_SERVER_NAME         "com.ukui.bluetooth"
#define KYLIN_BLUETOOTH_SERVER_PATH         "/com/ukui/bluetooth"
#define KYLIN_BLUETOOTH_SERVER_INTERFACE    "com.ukui.bluetooth"

class BluetoothDbus : public QObject
{
    Q_OBJECT
public:
    BluetoothDbus();
    ~BluetoothDbus();

    static BluetoothDbus *getInstance();

    bool getDefaultAdapterPower();
    void setDefaultAdapterPower(bool state);

    QString getDefaultAdapterAddress();
private:
    QDBusInterface *m_bluetoothDbusInterface = nullptr;

private slots:

};

//! 应用管理

#define KYLIN_APP_MANAGER_NAME         "com.kylin.AppManager"
#define KYLIN_APP_MANAGER_PATH         "/com/kylin/AppManager"
#define KYLIN_APP_MANAGER_INTERFACE    "com.kylin.AppManager"

class AppManagerDbus : public QObject
{
    Q_OBJECT
public:
    AppManagerDbus();
    ~AppManagerDbus();

    static AppManagerDbus *getInstance();

    bool LaunchApp(QString desktopFile);

    bool LaunchAppWithArguments(QString desktopFile,QStringList args);

private:
    QDBusInterface *m_appManagerDbusInterface = nullptr;

private slots:

};

//! upower

#define KYLIN_UPOWER_NAME         "org.ukui.upower"
#define KYLIN_UPOWER_PATH         "/upower"
#define KYLIN_UPOWER_INTERFACE    "org.ukui.upower"

class UpowerDbus : public QObject
{
    Q_OBJECT
public:
    UpowerDbus();
    ~UpowerDbus();

    static UpowerDbus *getInstance();
    bool getCanAdjustBacklight();

private:
    QDBusInterface *m_upowerDbusInterface = nullptr;

};

#endif // DBUSMANAGER_H
